package com.cauli.account.config.model.dto;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cauli.model.abstractQuery.AbstractPageQuery;
import com.cauli.account.config.model.entity.Config;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author Cauli
 * @date 2023-03-07 14:13
 * @description 系统设置添加参数
 */
@Data
@ApiModel(value = "ConfigQueryDTO", description = "系统设置查询参数")
public class ConfigQueryDTO extends AbstractPageQuery {
    @ApiModelProperty("系统设置标题")
    private String configTitle;

    @ApiModelProperty("系统设置名称")
    private String configName;

    @ApiModelProperty("系统设置分组")
    private String groupName;

    @Override
    public QueryWrapper toQueryWrapper() {
        return null;
    }

    @Override
    public LambdaQueryWrapper<Config> toLambdaQueryWrapper() {
        LambdaQueryWrapper<Config> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper
                .like(StrUtil.isNotEmpty(configName), Config::getConfigName, configName)
                .like(StrUtil.isNotEmpty(configTitle), Config::getConfigTitle, configTitle)
                .like(StrUtil.isNotEmpty(groupName), Config::getGroupName, groupName);
        return lambdaQueryWrapper;
    }
}
